Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

287
Views
¿Por qué vhtml no se renderiza anidado << correctamente?

Tengo una aplicación que usa enlaces dinámicos donde <> es una forma dinámica de obtener valor de la API. Pero cuando intento representarlo en vhtml, ni siquiera muestra el elemento principal. Lo quiero como Nombre: <<Name>> . ¿Cómo se puede lograr esto? . Adjunto el código de ejemplo.

 const app = new Vue({ el: '#app', data () { return { htmlText: '<p> Name : <<Name>> </p>' } } })
 <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script> <div id="app"> <span v-html="htmlText"></span> </div>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Además de las respuestas de Link y Xlm en vue: ¿escapar y representar una cadena HTML?

Analice la cadena entrante con una expresión regular que reemplace < con &lt; y > con &gt;

Tenga en cuenta que esto podría ser sólo una solución . Si desea una solución más limpia , debe hacerlo en la API .

En tu caso,

 const app = new Vue({ el: "#app", data() { return { htmlText: "<p> Name : <<Name>> </p>", }; }, methods: { htmlToText(html) { return html.replace(/<</g, "&lt;&lt;").replace(/>>/g, "&gt;&gt;"); }, }, });
 <div id="app"> <span v-html="htmlToText(htmlText)"></span> </div> <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!